#ifndef ITEM_H
#define ITEM_H

#include <QApplication>
#include <QColor>
#include <QGraphicsItem>
#include <QSet>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include "line.h"
#include "dlgproperties.h"

class Line;

static int id = 0;

class Item : public QGraphicsItem
{
public:
    Item();
    //iType equal 0 if node, 1 if device, 2 - comment, 3 - info
    Item(int iType);
    ~Item();

    void AddLine(Line * line);
    void RemoveLink(Line * line);
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QRectF boundingRect() const;
    QRectF outlineRect() const;
    void SetText(QString text, bool lType);
    QString GetText() const;
    int GetRoundness(double Size) const;
    void SetChild(Item * child);
    QList<Item *> GetChild() const;
    int GetType() const;
    int GetId() const;
    int GetChildId() const;
    void SetId(int id);
    void SetChildId(int id);
    void SetChildIds(QList<int> id);
    void SetParent(Item * parent);
    void SetParentId(int iID);
    Item * GetParent() const;
    float GetRectsWidth(QList<Item *> list, int iCount) const;
    void RemoveChild(Item * child);
    int GetChildCount() const;
    int GetParentId() const;
    QList<int> GetChildIds() const;
    int IsChild(int id) const;
    Item * GetChildAt(int iPos);
    int GetChildIdAt(int iPos);
    void OpenProperties();


private:
    QList<Line *> MyLine;
    QColor MyBackgroundColor;
    int iType;
    QString sText;
    QList<Item *> ChildItem;
    QList<int> ChildItemId;
    Item * ParentItem;
    int iParentItemId;
    int iID;
    int iChildId;

protected:
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
};

#endif // ITEM_H
